﻿//Created by Arcdemon//
//MapleCryptoAPI by aegisrunestone//
//Utilities class by aegisrunestone//
//Buffer class by aegisrunestone//
using System.Runtime.InteropServices;

namespace MapleCryptoAPI
{
    public enum _ERRCODE
    {
        ERR_NOERR = 00,
        ERR_INIT = 10,
        ERR_NOTINIT = 20,
        ERR_IV = 30,
        ERR_INPUT = 40,
        ERR_MEM = 50,
        ERR_LEN = 60,
    }

    public enum _CHECK
    {
        True = 1,
        False = 0,
    }

    public class MapleCrypto
    {
        [DllImport("MapleCrypto.dll")]
        public static extern _ERRCODE Initialize();

        [DllImport("MapleCrypto.dll")]
        public static extern _ERRCODE Finalize();

        [DllImport("MapleCrypto.dll")]
        public static extern _ERRCODE Encrypt(byte[] IV, byte[] InputBuffer, byte[] OutputBuffer, int Length);

        [DllImport("MapleCrypto.dll")]
        public static extern _ERRCODE Decrypt(byte[] IV, byte[] InputBuffer, byte[] OutputBuffer, int Length);

        [DllImport("MapleCrypto.dll")]
        public static extern _ERRCODE EncryptWithHeaderToClient(int Version, byte[] IV, byte[] InputBuffer, byte[] OutputBuffer, int Length);

        [DllImport("MapleCrypto.dll")]
        public static extern _ERRCODE EncryptWithHeaderToServer(int Version, byte[] IV, byte[] InputBuffer, byte[] OutputBuffer, int Length);

        [DllImport("MapleCrypto.dll")]
        public static extern _CHECK HeaderCheckFromClient(int Version, byte[] IV, byte[] Header, int Datalength);

        [DllImport("MapleCrypto.dll")]
        public static extern _CHECK HeaderCheckFromServer(int Version, byte[] IV, byte[] Header, int Datalength);

        [DllImport("MapleCrypto.dll")]
        public static extern _ERRCODE GenerateIV(byte[] IV);

        [DllImport("MapleCrypto.dll")]
        public static extern int GetPacketLengthFromHeader(byte[] Header);
    }
}
//Created by Arcdemon//
//MapleCryptoAPI by aegisrunestone//
//Utilities class by aegisrunestone//
//Buffer class by aegisrunestone//